home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1995 #5 & #6
/
Amiga Plus CD - 1995 - No. 5 and 6.iso
/
tex
/
src
/
specialhost
/
specialhost.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-07-30
|
22KB
|
818 lines
/* specialhost.c */
/**************************************************************/
/* */
/* Bitte alle Aenderungen im Programm deutlich */
/* markieren und mir zusenden. Ich werde dann */
/* versuchen immer eine einheitliche Version */
/* zusammenzubasteln. */
/* 30.07.90 (c) Georg Hessmann */
/* */
/* Bug's und Anregungen bitte an: */
/* hessmann@unipas.fmi.uni-passau.de */
/* oder an: */
/* Georg Hessmann */
/* Oberer Markt 7 */
/* 8712 Volkach */
/* Germany */
/* */
/* */
/* Program zur Auswertung der special Strings von TeX */
/* wird von "ShowDVI" und "DVIprint" verwendet. */
/* Das Programm muss im Hintergrund laufen noch bevor */
/* die anderen Programme gestartet werden. */
/* Die ist nur ein Beispiel, das die Arbeitsweise */
/* dokumentieren soll. */
/* */
/* Das bisherige Format des special Kommandos: */
/* \special{ifffile=name */
/* hoffset=fxx */
/* voffset=fxx */
/* hsize=fxx */
/* vsize=fxx } */
/* wobei f eine real-Zahl ist und xx eine Einheit wie */
/* in den anderen Programmen definiert. */
/* */
/* Das Programm benoetigt die "iff.library"! */
/* */
/* Version: */
/* */
/* -- 0.70 30.07.90 (hes) Georg Hessmann */
/* -- 0.71 16.11.90 Verbesserungen von 'flextr.c' */
/* (MiL) Michael Illgner */
/* -- 0.80 23.01.91 Verarbeitung von Farben! */
/* (MiL) Michael Illgner */
/* -- 0.81 04.04.91 Neue Skalierungsroutinen, */
/* `flextr.c' jetzt überflüssig */
/* Olaf `Olsen' Barthel */
/* -- 0.86 17.04.91 `flextr.c' wieder drin :) */
/* (hes) */
/* -- 0.90 30.05.91 Einbau von Pull-Down Menues */
/* Einbau eines Config-Files */
/* Auswahl Blitter on/off */
/* Groessenbegrenzung bei Blitter */
/* Invert-Routine */
/* (hes) */
/* -- 0.91 05.07.91 Zwei 'enforcer' hits behoben. */
/* GADGIMAGE-Gadgets eingefuehrt. */
/* PubScreen Support eingefuehrt. */
/* (hes) */
/* -- 0.92 10.07.91 Kleine Probleme im Zusammenspiel*/
/* Gadgets-Menues behoben. */
/* (hes) */
/* -- 0.93 11.07.91 Probleme im TPIC Teil behoben. */
/* Dazu werden nun float Zahlen als*/
/* Strings uebergeben, damit es */
/* keine Probleme FFP - IEEE gibt. */
/* Enforcer Hit in pline beseitigt.*/
/* CTRL-E veranlasst SpecialHost */
/* dazu, vom PubScr zu verschwinden*/
/* (hes) */
/* -- 0.94 30.07.91 Kleiner Bug in work_w_message */
/* behoben. */
/* (hes) */
/* */
/**************************************************************/
static char ver[] = "$VER: SpecialHost "VERSION" Copyright © 1990/91 Georg Heßmann. All Right Reserved. (last compiled: "__DATE__", "__TIME__")";
#define DOSNAMESIZE 150
#ifndef ZERO
# define ZERO 0L
#endif
#ifdef LATTICE
long _stack = 5120;
char * _procname = "SpecialHost";
long _priority = 0;
long _BackGroundIO = 1;
extern BPTR _Backstdout;
#endif
/* global variable */
static struct special_map spmap;
static char bitfilename[DOSNAMESIZE];
struct MsgPort *special_port = NULL;
IFFFILE ifffile = NULL;
struct BitMap *bmap = NULL;
short use_blitter = TRUE;
short invert_bmap = FALSE;
short is_os2 = FALSE;
short ECS_chips = FALSE;
UBYTE IFFColors[64];
UBYTE HAMColors[16][16][16];
WORD ColorTab[64];
extern struct Library *IFFBase; /* defined in specialwin.c */
extern struct GfxBase *GfxBase;
extern struct IntuitionBase *IntuitionBase;
static char *TPICstr[] = {
"no command",
"PN", "PA", "FP", "IP", "DA", "DT", "SP", "SP",
"AR", "IA", "SH", "SH", "SW", "BK", "TX", "overflow"
};
/* local funktions */
static void free_bmap (struct BitMap **bmap);
static int MyCompareDates (struct DateStamp *date1,
struct DateStamp *date2);
static int test_date (char *iffile, char *bitfile, long *ssum);
static void write_bmap (char *name,
struct BitMap *bmap,
long ssum,
long width, long height);
static int get_iff_size (char *name,
long *width,
long *height);
static struct BitMap *load_iff_picture (struct parse_result *res,
long *width,
long *height,
short to_chip);
static struct BitMap *work_with_message (struct special_msg *message,
int draw_modus, int base_dpi);
static int scale_bmap (struct special_map *map,
struct BitMap **old_bmap,
struct parse_result *res,
int base_dpi,
short to_chip);
void close_port_bitm(void)
{
if (special_port != NULL) {
DeletePort(special_port);
}
free_bmap(&bmap);
}
static void free_bmap(struct BitMap **bmap)
{
int i;
struct BitMap *map = (*bmap);
if (map != NULL)
{
for (i=0; i<map->Depth; i++)
{
if (map->Planes[i] != NULL)
{
FreeMem(map->Planes[i],map->BytesPerRow*map->Rows);
map->Planes[i] = NULL;
}
}
free(map);
*bmap = NULL;
}
}
static int MyCompareDates(struct DateStamp *date1, struct DateStamp *date2)
{
int ret = 1;
if (memcmp(date1,date2,sizeof(struct DateStamp)) == 0) {
ret = 0;
}
else {
if (date1->ds_Days > date2->ds_Days) {
ret = -1;
}
else {
if (date1->ds_Days == date2->ds_Days) {
if (date1->ds_Minute > date2->ds_Minute) {
ret = -1;
}
else {
if (date1->ds_Minute == date2->ds_Minute && date1->ds_Tick > date2->ds_Tick) {
ret = -1;
}
}
}
}
}
return ret;
}
static int test_date(char *iffile, char *bitfile, long *ssum)
{
struct FileLock *lock_iff, *lock_bit;
struct FileInfoBlock *fib_iff, *fib_bit;
int ret = FALSE;
FILE *file;
long buffer;
fib_iff = (struct FileInfoBlock *)malloc((unsigned)sizeof(struct FileInfoBlock));
fib_bit = (struct FileInfoBlock *)malloc((unsigned)sizeof(struct FileInfoBlock));
lock_iff = (struct FileLock *)Lock(iffile, ACCESS_READ);
lock_bit = (struct FileLock *)Lock(bitfile, ACCESS_READ);
if (fib_iff != NULL && fib_iff != NULL && lock_iff != NULL && lock_bit != NULL) {
if (Examine((BPTR)lock_iff,fib_iff)!=0 && Examine((BPTR)lock_iff,fib_iff)!=0) {
ret = (MyCompareDates(&(fib_bit->fib_Date), &(fib_iff->fib_Date)) > 0);
}
}
if (lock_iff) UnLock((BPTR)lock_iff);
if (lock_bit) UnLock((BPTR)lock_bit);
if (fib_iff) free(fib_iff);
if (fib_bit) free(fib_bit);
if (ret) {
if ((file = fopen(bitfile,"r")) != NULL) {
if (fread((char *)&buffer,4,1,file) == 1) {
if (buffer != MAGIC_WORD) {
ret = FALSE;
pline(" wrong magic word in file %s!",bitfile);
}
else {
if (fread((char *)&buffer,4,1,file) != 1) {
ret = FALSE;
}
else {
*ssum = buffer;
}
}
}
fclose(file);
}
}
return ret;
}
static void write_bmap(char *name, struct BitMap *bmap, long ssum, long width, long height)
{
FILE *bmap_file;
long buffer;
int i;
/* File Format: 4Bytes - magic word "SPEC" */
/* 4Bytes - sum of \special-string */
/* 4Bytes - length of rows in bits */
/* 4Bytes - number of rows */
/* rows */
/* length of one row is word (16Bit) aligned!! */
if ((bmap_file = fopen(name,"w")) == NULL) {
pline("Can't write to bitmap-file (%s)!",name);
return;
}
buffer = (long)MAGIC_WORD;
fwrite((char *)&buffer,4,1,bmap_file);
buffer = ssum;
fwrite((char *)&buffer,4,1,bmap_file);
buffer = width;
fwrite((char *)&buffer,4,1,bmap_file);
buffer = height;
fwrite((char *)&buffer,4,1,bmap_file);
for (i=0; i<bmap->Rows; i++) {
fwrite(bmap->Planes[0]+(i*bmap->BytesPerRow),1,bmap->BytesPerRow,bmap_file);
}
fclose(bmap_file);
}
static int get_iff_size(char *name, long *width, long *height)
{
struct BitMapHeader *bmhd;
if (IFFBase == NULL) {
if(!(IFFBase = OpenLibrary(IFFNAME,IFFVERSION))) {
pline("Copy the iff.library (Ver: %ld) to your LIBS: directory!",IFFVERSION);
return FALSE;
}
}
if(!(ifffile=OpenIFF(name))) {
pline("Error opening iff-file \"%s\"!",name);
return FALSE;
}
if(!(bmhd=GetBMHD(ifffile))) {
pline("BitMapHeader not found in iff-file \"%s\"",name);
return FALSE;
}
*width = bmhd->w;
*height = bmhd->h;
CloseIFF(ifffile);
ifffile = NULL;
return TRUE;
}
/* new by MiL */
/* calculate the gray values with gamma-correction */
static void make_colors(int numcolors, struct parse_result *res)
{
float r, g, b, gam;
float fak;
int i, ri, gi, bi;
r = res->red; g = res->green; b = res->blue; gam = res->gamma;
fak = 255.0*pow(15.0*(r+g+b), -gam);
for(i=0; i<numcolors; i++)
IFFColors[i] = (UBYTE)(fak*pow(((ColorTab[i] >> 8) & 0x0f)*r +
((ColorTab[i] >> 4) & 0x0f)*g +
((ColorTab[i] >> 0) & 0x0f)*b, gam));
if (res->mode == Ham)
for(ri=0; ri<16; ri++)for(gi=0; gi<16; gi++)for(bi=0; bi<16; bi++)
HAMColors[ri][gi][bi] = (UBYTE)(fak*pow(ri*r+gi*g+bi*b, gam));
}
static struct BitMap *load_iff_picture (struct parse_result *res, long *width, long *height, short to_chip)
{
struct BitMapHeader *bmhd;
struct BitMap *bmap;
int i, numcolors;
if ((bmap = malloc(sizeof(struct BitMap))) == NULL) {
pline("Not enough memory for bitmap-structure!!!");
return NULL;
}
for (i=0; i<8; i++) { /* importand */
bmap->Planes[i] = NULL;
}
if (IFFBase == NULL) {
if(!(IFFBase = OpenLibrary(IFFNAME,IFFVERSION))) {
pline("Copy the iff.library (Ver: %ld) to your LIBS: directory!",IFFVERSION);
free(bmap);
return NULL;
}
}
if(!(ifffile=OpenIFF(res->iffile))) {
pline("Error opening iff-file \"%s\"!",res->iffile);
free(bmap);
return NULL;
}
if(!(bmhd=GetBMHD(ifffile))) {
pline("BitMapHeader not found in iff-file \"%s\"",res->iffile);
free(bmap);
return NULL;
}
/* Olsen: Statt manueller Initialisierung besser
* durch die Systemroutine initialisieren
* lassen (BltBitMap bekommt sonst Probleme).
*/
InitBitMap(bmap,bmhd->nPlanes,bmhd->w,bmhd->h);
*width = bmhd->w; /* in pixel */
*height = bmhd->h; /* in pixel */
for (i=0; i<bmap->Depth; i++) {
if (to_chip) {
bmap->Planes[i] = AllocMem(bmap->BytesPerRow*bmap->Rows,MEMF_CHIP|MEMF_CLEAR);
}
else {
bmap->Planes[i] = AllocMem(bmap->BytesPerRow*bmap->Rows,MEMF_PUBLIC|MEMF_CLEAR);
}
if (bmap->Planes[i] == NULL) {
free_bmap(&bmap); /* gibt alles schon allozierte frei */
pline("NOT ENOUGH MEMORY!!! (%s-mem)", (to_chip) ? "chip" : "fast");
return NULL;
}
}
if (bmap->Depth > 1 && res->mode == BandW) {
pline("Warning: This mode can't work with more than 2 colors!");
}
/* bitmaps der Tiefe '1' brauchen keine color-map */
if (bmap->Depth > 1 && !(numcolors = GetColorTab(ifffile, ColorTab))) {
pline("picture has no colour table");
free_bmap(&bmap);
return NULL;
}
if (numcolors > 0) {
make_colors(numcolors, res);
}
if(!DecodePic(ifffile,bmap)) {
pline("Can't decode picture \"%s\"!",res->iffile);
free_bmap(&bmap);
return NULL;
}
if (invert_bmap) {
int inv_i, inv_size;
ULONG * inv_ptr;
/*
* I'm using longs here because it's more efficient on 32-bit-machines
* (A2500, A3000, A3001 Turbo Board etc.)
* The allocated memory chunk IS a multiple of 4 bytes!
*
*/
inv_size = (bmap->BytesPerRow*bmap->Rows)/4; /* size in long */
for(inv_i=0,inv_ptr = (ULONG *)bmap->Planes[0]; inv_i<inv_size; inv_i++) {
*(inv_ptr++) ^= 0xFFFFFFFF;
}
}
return bmap;
}
/* main function: verarbeitet die message und generiert eine Bitmap */
static struct BitMap *work_with_message(struct special_msg *message,
int draw_modus, int base_dpi)
{
struct parse_result res;
struct BitMap *bitmap = NULL;
char full_name[DOSNAMESIZE];
long width, height, ssum, ssum2;
char *str;
short to_chip; /* Blitter oder nicht */
to_chip = use_blitter;
pline("** received special string: (hres: %d, vres: %d)",
message->hresolution,message->vresolution);
pline(" \"%s\"",message->special_string);
res.iffile[0] = '\0';
res.hsize = 0.0;
res.vsize = 0.0;
res.hoffset = 0.0;
res.voffset = 0.0;
res.scale = 0.0;
res.hscale = 0.0;
res.vscale = 0.0;
res.hres = message->hresolution;
res.vres = message->vresolution;
res.mode = BandW; /* BandW, Gray, Color or Ham */
res.red = 1.0;
res.green = 1.0;
res.blue = 1.0;
res.gamma = 0.5;
ssum = ssum2 = 0;
for (str = message->special_string; str != NULL && *str != '\0'; ssum += (long)*str, str++);
ParseSpecial(message->special_string, &res);
if (res.mode != BandW && !(draw_modus == DRAW_BORDER || draw_modus == DRAW_RECT)) {
pline(" (Red,Green,Blue) = (%1.2f,%1.2f,%1.2f) Gamma = %1.2f",
res.red, res.green, res.blue, res.gamma);
}
spmap.hoffset = (long)(((float)message->hresolution * res.hoffset)+0.5);
spmap.voffset = (long)(((float)message->vresolution * res.voffset)+0.5);
message->ret = 0;
message->bmap = &spmap;
spmap.loc.map = NULL;
spmap.where_is = LOC_NONE;
if (res.iffile[0] != '\0') {
if (draw_modus == DRAW_BORDER || draw_modus == DRAW_RECT) {
if (get_iff_size(res.iffile,&width,&height)) {
spmap.width = width; /* in pixel */
spmap.height = height;
if (draw_modus == DRAW_BORDER) {
spmap.where_is = LOC_BORDER;
}
else {
spmap.where_is = LOC_RECTANGLE;
}
(void) scale_bmap(&spmap, &bitmap, &res, base_dpi, 0);
}
else {
pline("iff-file ERROR! (transferred no picture)");
message->ret = 5; /* not used */
}
}
else {
sprintf(full_name,"%s.%ldx%ld", res.iffile, res.hres, res.vres);
if ((draw_modus == DRAW_FILE || draw_modus == DRAW_FILE_B)
&& test_date(res.iffile,full_name,&ssum2) && ssum == ssum2) {
/* full_name juenger als iffile und special unveraendert */
if (draw_modus == DRAW_FILE) {
spmap.where_is = LOC_FILE;
}
else {
spmap.where_is = LOC_FILE_BORDER;
}
strcpy(bitfilename,full_name);
spmap.loc.filename = bitfilename;
}
else { /* iffile juenger als full_name */
/* Wie wird ausgewaehlt, welche Routine zum Scalieren */
/* verwendet wird: */
/* erster Versuch: Laden des Bildes in's Chip-Mem */
/* wenn das fehlschlaegt wird nur noch mit Fast-Mem */
/* und der `flextr.c' Routine gearbeitet. */
/* zweiter Versuch: Wenn das Bild ins Chip-Mem geladen */
/* ist, wird versucht es im Chip-Mem zu scalieren. */
/* schlaegt das ebenfalls fehl, wird doch wieder auf */
/* `flextr.c' zurueckgegriffen. */
/* einen NACHTEIL hat das Verfahren allerdings: */
/* falls die Ausgangsbitmap in das Chip-Mem passt, */
/* die Zielbitmap aber ins Fast-Mem gelegt werden */
/* muss, wird beim scalieren staendig auf Chip-Mem */
/* zugegriffen! Pech fuer A3000 Besitzer!! */
/* (man sollte in dem Fall die Ausgangsbitmap wieder */
/* freigeben.) */
/* FEHLER!! */
/* Hoehe/Breite groesser 1024 Pixel koennen nicht vom */
/* (alten ?) Blitter verarbeitet werden!! */
bitmap = load_iff_picture(&res,&width,&height, to_chip); /* chip-mem */
if (bitmap == NULL) {
if (ifffile != NULL) {
CloseIFF(ifffile);
ifffile = NULL;
}
bitmap = load_iff_picture(&res,&width,&height, 0); /* fast-mem */
to_chip = 0;
}
if (bitmap != NULL) {
if (draw_modus == DRAW_IN_MEM_B || draw_modus == DRAW_FILE_B) {
spmap.where_is = LOC_BITMAP_BORDER;
}
else {
spmap.where_is = LOC_BITMAP;
}
spmap.width = width; /* in pixel */
spmap.height = height; /* in pixel */
if (scale_bmap(&spmap, &bitmap, &res, base_dpi, to_chip) == 2) {
/* kein CHIP-MEM verfuegbar */
to_chip = 0;
scale_bmap(&spmap, &bitmap, &res, base_dpi, to_chip);
}
spmap.loc.map = (unsigned long *)bitmap->Planes[0];
if (draw_modus != DRAW_IN_MEM && draw_modus != DRAW_IN_MEM_B) {
pline("create file \"%s\"",full_name);
write_bmap(full_name, bitmap, ssum, spmap.width, spmap.height);
}
}
else {
pline("bitmap ERROR! (transferred no picture)");
message->ret = 5; /* not used */
}
}
}
}
return bitmap;
}
static int scale_bmap (struct special_map *map, struct BitMap **old_bmap,
struct parse_result *res, int base_dpi, short to_chip)
{
USHORT new_width, new_height, map_width, map_height;
struct BitMap *new_bmap;
int i;
/* to_chip: 0 = fast-mem, 1 = chip-mem */
/* RETURN: 0 = ok, 1 = *no* mem, 2 = no chip-mem */
struct DateStamp Date1, Date2;
long diff;
new_width = (map->width * res->hres * 10 + 5) / (base_dpi * 10);
new_height = (map->height * res->vres * 10 + 5) / (base_dpi * 10);
if (res->hsize != 0.0) {
/* width = hsize * hres */
new_width = (long)((res->hsize * (float)res->hres * 10.0 + 5.0) / 10.0);
}
if (res->vsize != 0.0) {
/* height = vsize * vres */
new_height = (long)((res->vsize * (float)res->vres * 10.0 + 5.0) / 10.0);
}
if (ECS_chips) { /* Die genaue Groesse kenn ich nicht (??) */
if ((new_width > (1<<15)-1) || (new_height > (1<<15)-1)) {
to_chip = FALSE;
}
}
else {
if ((new_width > 1023) || (new_height > 1023)) {
to_chip = FALSE;
}
}
if (new_width != map->width || new_height != map->height) {
if (map->where_is == LOC_BORDER || map->where_is == LOC_RECTANGLE) {
map->width = new_width;
map->height = new_height;
}
else {
if (map->where_is == LOC_BITMAP || map->where_is == LOC_BITMAP_BORDER) {
if ((new_bmap = malloc(sizeof(struct BitMap))) == NULL) {
pline("NOT ENOUGH MEMORY!!! (picture not resized)");
return 1; /* *no* mem */
}
for (i=0; i<8; i++) { /* important */
new_bmap->Planes[i] = NULL;
}
/* Olsen: Initialisierung durch Systemroutine. */
InitBitMap(new_bmap,1,new_width,new_height);
/* new_bmap->Flags = (*old_bmap)->Flags; (???) */
if (to_chip) {
new_bmap->Planes[0] = AllocMem(new_bmap->BytesPerRow*new_bmap->Rows,MEMF_CHIP|MEMF_CLEAR);
}
else {
new_bmap->Planes[0] = AllocMem(new_bmap->BytesPerRow*new_bmap->Rows,MEMF_PUBLIC|MEMF_CLEAR);
}
if (new_bmap->Planes[0] == NULL) {
free_bmap(&new_bmap);
pline("NOT ENOUGH MEMORY!!! (%s-mem)", (to_chip) ? "chip" : "fast");
if (to_chip) {
return 2; /* no chip mem */
}
else {
return 1; /* no fastmem */
}
}
DateStamp(&Date1);
map_width = map->width; map_height = map->height;
if (res->mode == BandW) {
if (to_chip) {
if (is_os2) {
struct BitScaleArgs bsa;
bsa.bsa_SrcX = 0;
bsa.bsa_SrcY = 0;
bsa.bsa_SrcWidth = map->width;
bsa.bsa_SrcHeight = map->height;
bsa.bsa_XSrcFactor = map->width;
bsa.bsa_YSrcFactor = map->height;
bsa.bsa_DestX = 0;
bsa.bsa_DestY = 0;
/** bsa.bsa_DestWidth = ; **/
/** bsa.bsa_DestHeight = ; **/
bsa.bsa_XDestFactor = new_width;
bsa.bsa_YDestFactor = new_height;
bsa.bsa_SrcBitMap = *old_bmap;
bsa.bsa_DestBitMap = new_bmap;
bsa.bsa_Flags = 0;
BitMapScale(&bsa);
}
else {
/* Olsen: Skalierung mit dem Blitter statt Zeile für
* Zeile.
*/
if (!ResizeBitMap(*old_bmap,new_bmap,map_width,map_height,new_width,new_height)) {
FreeMem(new_bmap->Planes[0],new_bmap->BytesPerRow*new_bmap->Rows);
free_bmap(&new_bmap);
pline("NOT ENOUGH MEMORY!!! (chip-mem)");
return 2;
}
}
}
else {
extract_one((*old_bmap)->Planes[0], new_bmap->Planes[0],
(*old_bmap)->BytesPerRow, new_bmap->BytesPerRow,
map_width, map_height,
new_width, new_height);
}
}
else {
dither(*old_bmap, map_width, new_bmap, new_width, res->mode == Ham);
}
DateStamp(&Date2);
diff = (Date2.ds_Days - Date1.ds_Days) * (24 * 60);
diff = (diff + (Date2.ds_Minute - Date1.ds_Minute)) * 60 * TICKS_PER_SECOND;
diff += Date2.ds_Tick - Date1.ds_Tick;
pline(" Time: %7ld.%02ld Seconds", diff / TICKS_PER_SECOND,
((diff % TICKS_PER_SECOND) * 100) / TICKS_PER_SECOND);
map->width = new_width;
map->height = new_height;
free_bmap(old_bmap);
*old_bmap = new_bmap;
}
}
}
return 0;
}
void install_special_port(struct MsgPort **special_port)
{
Forbid();
*special_port = FindPort(SPECIAL_PORT);
if (*special_port != NULL) {
Permit();
Fatal(NOT_FIRST);
}
*special_port = (struct MsgPort *)CreatePort(SPECIAL_PORT,0L);
Permit();
if (*special_port == NULL) {
Fatal(NO_PORT);
}
}
long work_with_special(int draw_modus, int base_dpi)
{
struct special_msg *message;
long ret = 0;
while ((message = (struct special_msg *)GetMsg(special_port)) != NULL) {
if (message != NULL) {
switch (message->action) {
case AC_SEND_SPECIAL:
bmap = work_with_message(message, draw_modus, base_dpi);
message->action = AC_REPLY_SPECIAL;
ReplyMsg(&(message->msg));
WaitPort(special_port);
message = (struct special_msg *)GetMsg(special_port);
if (message == NULL) {
Fatal(NO_MESSAGE);
}
if (message->action != AC_OK_BITMAP) {
pline("*** I have expected AC_REPLY_SPECIAL!!");
pline(" I found '%d' (see special.h)!",message->action);
}
message->action = AC_REPLY_BITMAP;
message->ret = 0;
ReplyMsg(&(message->msg));
if (ifffile != NULL) {
CloseIFF(ifffile);
ifffile = NULL;
}
free_bmap(&bmap); /* bmap = NULL; macht nun schon free_bmap() */
break;
case AC_SEND_TPIC:
/* pline("receive TPIC command %s",TPICstr[message->tpic->tpic_com]); */
work_with_tpic(message->tpic, message->dmap, message->hresolution, message->vresolution);
message->action = AC_REPLY_TPIC;
message->ret = 0;
ReplyMsg(&(message->msg));
break;
default:
pline("*** Unknown action!?");
pline(" Maybe you need a newer SpecialHost version!");
message->action = AC_REPLY_UNKNOWN;
message->ret = 0;
ReplyMsg(&(message->msg));
break;
}
}
}
return ret;
}